<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/jsp/declare.jsp" %>

<!DOCTYPE html>
<html>
<head>
	<base href="<%=basePath %>" />
	<title>房间-列表</title>
	<%@ include file="/common/jsp/common.jsp" %>
	
	<script>
	function bedList(dom) {
		var roomId = dom.parentNode.id;
		if (roomId)
			redirect("mvc/main/${houseId}/" + roomId + "/bedList.htm");
	}
	function roomEdit(dom) {
		var roomId = dom.parentNode.parentNode.id;
		if (roomId)
			redirect("mvc/main/${houseId}/" + roomId + "/roomEdit.htm");
	}
	function roomAdd() {
		redirect("mvc/main/${houseId}/add/roomEdit.htm");
	}
	function houseList() {
		redirect("mvc/main/houseList.htm");
	}
	</script>
</head>
<body id="room">
	<div class="picBar">
		<img src="aizu/images/room/room.jpg" />
	</div>
	<div class="address">地址：${address }</div>
	<table border="0" cellspacing="0" borderColor="#DADADA">
		<thead>
			<tr>
				<th>房间名称</th>
				<th>总床位</th>
				<th>剩余床位</th>
				<%-- <th>价格(元)</th> --%>
				<th>状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="room" items="${rooms}">
			<tr id="${room.id }">
				<td onclick="bedList(this)">${room.name }</td>
				<td onclick="bedList(this)">${!empty room.bed_count ? room.bed_count : 0 }</td>
				<td onclick="bedList(this)">${!empty room.bed_surplus_count ? room.bed_surplus_count : 0 }</td>
				<%-- <td onclick="bedList(this)"><fmt:formatNumber value="${!empty room.room_price ? room.room_price : 0 }" pattern="#,##0.#"/></td> --%>
				<td onclick="bedList(this)">${room.bed_surplus_count > 0 ? '出租' : '满租' }</td>
				<c:if test="${room.bed_count eq 0 or room.bed_count eq room.bed_surplus_count  }">
				<td><button class="edit" onclick="roomEdit(this)">编辑</button></td>
				</c:if>
				<c:if test="${room.bed_count ne room.bed_surplus_count }">
				<td><button class="cantEdit">编辑</button></td>
				</c:if>
			</tr>
			</c:forEach>
		</tbody>
	</table>
	<div class="button-bar x2 center">
		<div class="button-bar center fixed bottom">
			<input type="button" value="新增房间" class="submit" onclick="roomAdd()" />
			<input type="button" value="返回房屋" class="submit" onclick="houseList()" />
		</div>
	</div>
</body>
</html>